﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DataAccess_Layer
{
    public static class RoleDAC
    {
        public static object layHet()
        {
            return DataAccessHelper.DB.aspnet_Roles.Select(role => new { RoleId = role.RoleId, RoleName = role.RoleName });
        }

        public static object layHetTruAdmin()
        {
            return DataAccessHelper.DB.aspnet_Roles.Where(r=>!r.RoleName.Contains("admin")).Select(role => new { RoleId = role.RoleId, RoleName = role.RoleName });
        }

        public static bool isAdmin(string roleID)
        {
            return DataAccessHelper.DB.aspnet_Roles.Where(r => r.RoleName.Contains("admin") && r.RoleId == new Guid(roleID)).Select(r => r).Count() > 0;
        }

        public static Guid getAdminRoleID()
        {
            return DataAccessHelper.DB.aspnet_Roles.Where(r => r.RoleName.Contains("admin")).Select(role => role.RoleId).First();
        }
    }
}
